package com.ruoyi.jproom.service.impl;

import com.ruoyi.jproom.entity.DemandInfo;
import com.ruoyi.jproom.mapper.DemandHousingMapper;
import com.ruoyi.jproom.service.DemandHousingService;
import com.ruoyi.jproom.utils.BaseResult;
import com.ruoyi.jproom.utils.ResultEnum;
import com.ruoyi.jproom.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zeo
 * @explain 我要租房 我要买房 实现类
 * @date 2020/7/27 11:08
 */
@Service
public class DemandHousingServiceImpl implements DemandHousingService {

    @Autowired
    DemandHousingMapper demandHousingMapper;

    @Override
    public BaseResult insertMeBuyHousingEntrust(DemandInfo demandInfo) {
        demandInfo.setDemandId(Utils.getUUID());
        if (demandHousingMapper.insertMeBuyHousingEntrust(demandInfo) > 0) {
            return BaseResult.build(ResultEnum.SUCCESS);
        } else {
            return BaseResult.build(ResultEnum.FAILURE);
        }
    }

    @Override
    public BaseResult insertMeRentHousingEntrust(DemandInfo demandInfo) {
        demandInfo.setDemandId(Utils.getUUID());
        if (demandHousingMapper.insertMeRentHousingEntrust(demandInfo) > 0) {
            return BaseResult.build(ResultEnum.SUCCESS);
        } else {
            return BaseResult.build(ResultEnum.FAILURE);
        }
    }

    @Override
    public List<DemandInfo> findMeBuyHousingEntrustList(DemandInfo demandInfo) {
        return demandHousingMapper.findMeBuyHousingEntrustList(demandInfo);
    }

    @Override
    public List<DemandInfo> findMeRentHousingEntrustList(DemandInfo demandInfo) {
        return demandHousingMapper.findMeRentHousingEntrustList(demandInfo);
    }

    @Override
    public int changeIsHandle(String demandId, String isHandle) {
        return demandHousingMapper.changeIsHandle(demandId,isHandle);
    }

    @Override
    public int toVoid(String demandId) {
        return demandHousingMapper.toVoid(demandId);
    }
}
